<!-- 退会 -->
<template>
    <a-modal
        :maskClosable="false"
        title="退会详情"
        centered
        :width="800"
        v-model="visible"
        @ok="handleSubmit"
    >
    <a-form-model ref="ruleForm" :model="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
        <a-form-model-item v-if="disabled" label="退会时间">
            <span>{{info.quitTime}}</span>
        </a-form-model-item>
        <a-form-model-item label="退会原因">
            <a-textarea v-model="form.remark" placeholder="请输入退会原因" :rows="5" :disabled="disabled" />
        </a-form-model-item>
        <a-form-model-item v-if="disabled" label="操作人">
            <span>{{info.operuserName}}</span>
        </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import { memberQuit, quitInfo } from '@/api/member/member'
export default {
    props: ['disabled'],
    components: {},
    data() {
        return {
            title: '分配专员',
            visible: false,
            form: {
                id: undefined,
                remark: undefined,
            },
            info: {}
        }
    },
    computed: {},
    watch: {},
    methods: {
        show(row){
            this.form.id = row.id
            this.form.remark = row.remark
            if(this.disabled) this.getQuitInfo()
            this.visible = true
            
        },
        async getQuitInfo(){
            try {
                let res = await quitInfo(this.form.id)
                this.info = res.data || {}
                this.form.remark = this.info.remarks
            } catch (error) {
                console.error(error)
            }
        },
        async handleSubmit(){
            if(this.disabled) return this.visible = false
            this.$refs.ruleForm.validate(async valid => {
                if(valid){
                    let { code, msg } = await memberQuit({ ...this.form })
                    this.$message[code === 0 ? 'success' : 'error'](msg)
                    if(code === 0){
                        this.$emit('success')
                        this.visible = false
                    }
                }
            })
        }
    },
    created() {

    },
    mounted() {

    },
}
</script>
<style scoped>

</style>